#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>
//int main()
//{
//  printf("程序开始运行\n");
//  if(fork()==0)
//  {
//    printf("child process , pid : %d\n" , getpid());
//    int n = execl("./other.exe" , "other.exe" , NULL);
//    exit(1);
//  }
//  waitpid(-1,NULL,0);
//  printf("程序运行结束\n");
//  return 0;
//}
int main()
{
  printf("程序开始运行\n");
  if(fork()==0)
  {
    char* const argv[]={
      (char* const)"other.exe",
      (char* const)"-a",
      (char* const)"-b",
      NULL
    };
char *const addenv[] = {
    (char *const)"MYVAL=123456789",
    (char *const)"MYVAL1=123456789",
    (char *const)"MYVAL2=123456789",
    NULL
};
    int i = 0;
    for(i=0 ; addenv[i] ; i++)
    {
      putenv(addenv[i]);  
    }
    extern char **environ;
    int n = execvpe("./other.exe",argv,environ);
   //int n = execv("./other.exe", argv);
   // execvpe("./other.exe",argv,env);
   //int n = execv("/usr/bin/ls" , argv);
   //int n = execlp("ls","ls","-a","-l",NULL);
   //int n = execl("/usr/bin/ls" , "ls" , "-a" , "-l" , NULL);
    exit(1);
  }
  waitpid(-1,NULL,0);
  printf("程序运行结束\n");
  return 0;
}
//int main()
//{
//  printf("程序开始运行\n");
//  int n = execl("/usr/ls" , "ls" , "-a" , "-l" , NULL);
//  printf("程序运行结束 : %d\n" , n);
//  return 0;
//}
